package com.example.springbott.wx_controller;

import com.example.springbott.bean.BaseRespVo;
import com.example.springbott.bean.MarketStorage;
import com.example.springbott.wx_service.WXStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * 上传图片
 *
 * @author silic xia
 * @since 2022/11/22 12:28
 */
@RequestMapping("wx/storage")
@RestController
public class WXStorageController {

    @Autowired
    WXStorageService wxStorageService;

    /**
     *  上传图片
     *
     *  wx/storage/upload
     * @param /null
     * @return  addTime: "2022-11-22 12:27:26"
     *           id: 293
     *           key: "5gyvforlewb6dunog5hx.jpeg"
     *           name: "fEAh0UnVSkCU513f7389639759b720da663fb0da6841.jpeg"
     *           size: 608106
     *           type: "image/jpeg"
     *           updateTime: "2022-11-22 12:27:26"
     *           url: "http://182.92.235.201:8083/wx/storage/fetch/5gyvforlewb6dunog5hx.jpeg"
     *       data:{}
     *       errmsg: "æå"
     *       errno: 0
     * @author silic xia
     * @since 2022/11/22 12:28
     */
    @RequestMapping("upload")
    public BaseRespVo wxStorageUpload(HttpServletRequest req, MultipartFile file){
        MarketStorage data = wxStorageService.wxStorageUpload(req,file);
        return BaseRespVo.ok(data);
    }
}

